<html>
<head><meta charset="utf-8"><title>mir to hir FieldDef · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/mir.20to.20hir.20FieldDef.html">mir to hir FieldDef</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="240450336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/mir%20to%20hir%20FieldDef/near/240450336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Lattuada <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/mir.20to.20hir.20FieldDef.html#240450336">(May 27 2021 at 11:16)</a>:</h4>
<p>Hi folks! (I'm working on yet another verifier for rust as part of a research project) I have a question: if I have a <code>rustc_middle::ty::FieldDef</code>, can I somehow easily get the corresponding <code>rustc_hir::FieldDef</code>? Through TyCtxt or TypeckResults maybe? I'm currently using <code>TyCtxt::hir().get_if_local(field_def.did)</code> but it feels like there may be a more straightforward approach. Thanks!</p>



<a name="240451519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/mir%20to%20hir%20FieldDef/near/240451519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/mir.20to.20hir.20FieldDef.html#240451519">(May 27 2021 at 11:29)</a>:</h4>
<p>The hir is only available for the local crate. The mir may be from a different crate. Why do you need the hir field def?</p>



<a name="240452011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/mir%20to%20hir%20FieldDef/near/240452011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Lattuada <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/mir.20to.20hir.20FieldDef.html#240452011">(May 27 2021 at 11:34)</a>:</h4>
<p>Ah, good point, I should be careful not relying on that. I'm trying to figure out if the field's type was a type parameter in the struct def (for "reasons" related to boxing for the verifier).</p>



<a name="240452218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/mir%20to%20hir%20FieldDef/near/240452218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Lattuada <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/mir.20to.20hir.20FieldDef.html#240452218">(May 27 2021 at 11:36)</a>:</h4>
<p>Ah, I figured it out! (I think) <code>TyCtxt::type_of</code>. Thank you!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>